import { tradeRequest } from '@/request';

// 某个商品属性类型
export interface AttrListItemType {
  id?:number,
  attrName:string,
  categoryId:number,
  categoryLevel:number,
  attrValueList:AttrValueListType[],
  selectData?:string; // 新增属性 用来在skuform页面收集选中
}

// 商品属性列表的类型
export type AttrListType = AttrListItemType[]



//某个属性内 列表的类型
export interface AttrValueListType {
  id?:number,
  valueName:string,
  attrId:number | undefined,
  isEdit?:boolean // 新增的属性 代表编辑模式和查看模式
}


// 获取商品属性列表
export const reqAttrList = (category1Id:number,category2Id:number,category3Id:number) => (
  tradeRequest.get<null,any>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
)

// 删除某个属性
export const reqDeleteAttr = (attrId:number) => (
  tradeRequest.delete<any,null>(`/admin/product/deleteAttr/${attrId}`)
)

// 新增或修改属性
export const reqUpdateAddAttr = (newAttr:any) => (
  tradeRequest.post<any,null>(`/admin/product/saveAttrInfo`,newAttr)
)



// 三级联动列表接口

// 获取一级分类数据接口
export const reqCategory1 = () => (
  tradeRequest.get<any,any>(`/admin/product/getCategory1`)
)

// 二级分类
export const reqCategory2 = (category1Id:number) => (
  tradeRequest.get<any,any>(`/admin/product/getCategory2/${category1Id}`)
)

// 三级分类
export const reqCategory3 = (category2Id:number) => (
  tradeRequest.get<any,any>(`/admin/product/getCategory3/${category2Id}`)
)

